﻿using HR60_PanelSoft.Model;
using HR60_PanelSoft.Model.BaseModel;
using HR60_PanelSoft.NetWork.Base;
using HR60_PanelSoft.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR60_PanelSoft.NetWork.Sender
{
    class Sender_0112:BaseSender
    {
        public Sender_0112(byte panelNo, Panel panel, int pbNum, PanelButton panelButton)
        {

            byte[] data = new byte[17];

            int i = 0;
          
            Scene s = panelButton.getMappingScene();
            if (s == null)
                return;
            SceneType st = s.type;
            data[i++] = (byte)((int)st + 30);
            data[i++] = (byte)(Proj.currentProj.scenes.IndexOf(s) + 1);
         
            string name = panelButton.displayName;
            byte[] nameByte = ByteUils.china2Hex(name);
            int length = nameByte.Length;

            if (length > 14)
            {
                length = 14;

            }



            data[i++] = (byte)length;
            for (int j = 0; j < length; j++)
            {
                data[i++] = nameByte[j];

            }

            
            this.package = Package.getPackage(0x01, 0x12, panelNo, (byte)pbNum, data);

        }

    }
}
